package FileCopy;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class FileCopyNIO {
    public static void main(String[] args) {
        try (FileChannel inputChannel = new FileInputStream("data.bin").getChannel();
             FileChannel outputChannel = new FileOutputStream("dataTargetNIO.bin").getChannel()){
            long start = System.currentTimeMillis();
            outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
            long end = System.currentTimeMillis();
            System.out.println("Time: " + (end - start) + " ms");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
